package com.ts.mapper.achievement;

import com.ts.entity.ScientificResearchProject;
import org.apache.ibatis.annotations.*;

@Mapper
public interface ScientificResearchProjectMapper {

    /**
     * 存入一条科研项目成果数据并且主键返回
     */
    @Insert("INSERT INTO `tianshi-college-teacher-system-test`.ts_scientific_research_project (" +
            "achievement_type, is_first_principal, is_first_in_unit, project_name, project_number, " +
            "is_host, project_source, project_nature, project_level, research_type, " +
            "subject_category, cooperation_form, industry_university_enterprise, award_situation, " +
            "total_funding, school_funding, approval_time, conclusion_time, remark, evidence_material, " +
            "create_by, create_time, update_by, update_time" +
            ") VALUES (" +
            "#{achievementType}, #{isFirstPrincipal}, #{isFirstInUnit}, #{projectName}, #{projectNumber}, " +
            "#{isHost}, #{projectSource}, #{projectNature}, #{projectLevel}, #{researchType}, " +
            "#{subjectCategory}, #{cooperationForm}, #{industryUniversityEnterprise}, #{awardSituation}, " +
            "#{totalFunding}, #{schoolFunding}, #{approvalTime}, #{conclusionTime}, #{remark}, #{evidenceMaterial}, " +
            "#{createBy}, #{createTime}, #{updateBy}, #{updateTime}" +
            ")")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    void save(ScientificResearchProject scientificResearchProject);

    /**
     * 根据ID查询科研项目
     */
    @Select("SELECT * FROM `tianshi-college-teacher-system-test`.ts_scientific_research_project WHERE id = #{id}")
    ScientificResearchProject getById(Long id);

    /**
     * 更新科研项目
     */
    @Update("UPDATE `tianshi-college-teacher-system-test`.ts_scientific_research_project SET " +
            "achievement_type = #{achievementType}, " +
            "is_first_principal = #{isFirstPrincipal}, " +
            "is_first_in_unit = #{isFirstInUnit}, " +
            "project_name = #{projectName}, " +
            "project_number = #{projectNumber}, " +
            "is_host = #{isHost}, " +
            "project_source = #{projectSource}, " +
            "project_nature = #{projectNature}, " +
            "project_level = #{projectLevel}, " +
            "research_type = #{researchType}, " +
            "subject_category = #{subjectCategory}, " +
            "cooperation_form = #{cooperationForm}, " +
            "industry_university_enterprise = #{industryUniversityEnterprise}, " +
            "award_situation = #{awardSituation}, " +
            "total_funding = #{totalFunding}, " +
            "school_funding = #{schoolFunding}, " +
            "approval_time = #{approvalTime}, " +
            "conclusion_time = #{conclusionTime}, " +
            "remark = #{remark}, " +
            "evidence_material = #{evidenceMaterial}, " +
            "update_by = #{updateBy}, " +
            "update_time = #{updateTime} " +
            "WHERE id = #{id}")
    void update(ScientificResearchProject scientificResearchProject);

    /**
     * 根据ID删除科研项目
     */
    @Delete("DELETE FROM `tianshi-college-teacher-system-test`.ts_scientific_research_project WHERE id = #{id}")
    void delete(Long id);
}